package com.homson.coreservice.serviceapp.account;

import com.homson.coreservice.serviceapi.query.AccountQueryApi;
import com.homson.coreservice.servicecommon.request.AccountQueryRequest;
import com.homson.coreservice.servicecommon.request.PageRequestParameter;
import com.homson.coreservice.servicecommon.response.EntityResponse;
import com.homson.coreservice.servicecommon.response.PageResponse;
import com.homson.coreservice.servicecommon.vo.AccountVO;
import com.homson.servicedomain.domain.account.AccountRenderCommand;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Collections;
import java.util.List;

/**
 * @author: homson_leo
 * @contact: hey_超级巨星（Homson_Leo）- 刘泓岑 1196816884@qq.com
 * @time: 2025/11/8 3:25 PM
 **/
@Service
@Slf4j
public class AccountQueryService implements AccountQueryApi {
    
    @Resource
    private AccountRenderCommand accountRenderCommand;
    @Override
    public PageResponse<List<AccountVO>> queryAccountList(PageRequestParameter<AccountQueryRequest> request) {
        try{
            Long userId = request.getBody().getUserId();
            List<AccountVO> accountVOS = accountRenderCommand.queryAccountListRender(userId, request.getPage(), request.getSize());
            return PageResponse.ok(accountVOS,request.getPage(), request.getSize());
        }catch (Exception e){
            return PageResponse.fail(e.getMessage());
        }
    }
}
